package cn.lizheng.web;

import cn.lizheng.dao.AdmininfoDAO;
import cn.lizheng.dao.AdmininfoDAOImpl;
import cn.lizheng.pojo.Admininfo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/adminupdate")
public class AdminUpdate extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");

        String username = req.getParameter("username");
        String password = req.getParameter("password");
        String picurl = req.getParameter("picurl");
        String adminid = req.getParameter("id");
        Admininfo p = new Admininfo();
        p.setUsername(username);
        p.setPassword(password);
        p.setPicurl(picurl);
        p.setAdminid(Integer.parseInt(adminid));
        AdmininfoDAO dao = new AdmininfoDAOImpl();
        dao.update(p);
        //页面跳转
        req.getRequestDispatcher("adminList").forward(req, resp);

    }
}
